<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">


    <ui:composition template="/WEB-INF/faces/template.xhtml">

        <!-- new title -->
        <ui:define name="title">
            <h:outputText value="MyPage: #{sessionScope['loginUser'].name}" />
        </ui:define>

        <!-- new content -->
        <ui:define name="content">

            <!-- Check login -->
            <ui:include src="/resources/include/checkLogin.xhtml" />

            <h1>
                <h:outputText value="Welcome: #{sessionScope['loginUser'].name}" />
            </h1>

            <h2>
                Your bookings:
            </h2>

            <h:form>
                <p:dataTable id="products" value="#{myPageControllerBean.mybookings}" var="booking">

                    <p:column sortBy="#{booking.bookDate}" >
                        <f:facet name="header">
                            <h:outputText value="Booking Date" />
                        </f:facet>
                        <h:outputText value="#{booking.bookDate}" />
                    </p:column>

                    <p:column sortBy="#{booking.startDate}" >
                        <f:facet name="header">
                            <h:outputText value="Start Date" />
                        </f:facet>
                        <h:outputText value="#{booking.startDate}" />
                    </p:column>

                    <p:column sortBy="#{booking.endDate}" >
                        <f:facet name="header">
                            <h:outputText value="End Date" />
                        </f:facet>
                        <h:outputText value="#{booking.endDate}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Cancel booking" />
                        </f:facet>
                        <h:commandButton value="Cancel booking" action="#{myPageControllerBean.removeBooking(myPageControllerBean.getMyBooking(booking.id))}" />
                    </p:column>

                </p:dataTable>
            </h:form>

        </ui:define>

    </ui:composition>
</html>

